//+------------------------------------------------------------------+
//|                                                order_history.mq4 |
//|                               Copyright 2012, MAG.Software.Forex |
//|                                                              --- |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MAG.Software.Forex"
#property link      "---"



#define  ORDER_HISTORY_MAX          1000

int            order_id_history[ORDER_HISTORY_MAX];
int            curent_pos = 0;




bool addOrder2History(int orderid)
{
  bool result = true;
  if(curent_pos < ORDER_HISTORY_MAX) {
   order_id_history[curent_pos] = orderid;
   curent_pos = curent_pos + 1;
  } else
   result = false;
  return (result);
}

bool clearOrderHistory()
{
  int icount = 0;
  for(; icount < ORDER_HISTORY_MAX; icount ++)
  {
    order_id_history[icount] = 0;
  }
  curent_pos = 0;
  return (true);
}

int getHistoryMaxSize()
{
  return (ORDER_HISTORY_MAX);
}

int getOrderInHistory()
{
  return (curent_pos);
}

int getOrderIDFromHistory(int id)
{
  if(id < ORDER_HISTORY_MAX)
   return (order_id_history[id]);
  return (-1);
}

int getOrderTypeFromHistory(int id)
{
  if(curent_pos < 0 || id >= ORDER_HISTORY_MAX)
    return (-1);
  if(!OrderSelect(order_id_history[id], SELECT_BY_TICKET, MODE_HISTORY))
    return (OrderType());
}